<script>
import { onShow, onHide, onLaunch } from '@dcloudio/uni-app';
import { defineComponent, getCurrentInstance, onMounted } from 'vue';
import { useStore } from 'vuex';

export default defineComponent({
  setup() {
    const store = useStore();
    const setPageHide = (data = false) => {
      return store.commit('page/SET_PAGE_HIDE', data);
    };

    onShow(() => {
      setPageHide(false);
    });
    onHide(() => {
      setPageHide(true);
    });

    onLaunch(async () => {
      const { appContext } = getCurrentInstance();
      console.log(appContext.config.globalProperties.env);
    });

    onMounted(() => {
      const { proxy } = getCurrentInstance();
      console.log('$Route', proxy.$Route);
    });

    uni.onKeyboardHeightChange((res) => {
      console.log('键盘变化：', res);
      store.commit('keyboard/SET_KEYBOARD_HEIGHT', res);
    });

    store.dispatch('user/getUserInfo');

    // 因为开发工具内无法看到store状态，这里输出一下，方便查看
    return {
      store: store.state,
    };
  },
});
</script>

<style lang="scss">
@import url('@/style/tailwind.css');
page {
  min-height: 100vh;
  box-sizing: border-box;
  font-family: SourceHanSansCN-Regular, SourceHanSansCN;
}

view,
text,
scroll-view {
  box-sizing: border-box;
}

input {
  font-size: 24rpx;
  color: #333;
  height: 40rpx;
  line-height: 40rpx;

  &::placeholder {
    font-size: 24rpx;
    color: #999;
  }
}
.u-textarea {
  font-size: 15px;
}
.u-textarea__field {
  font-size: inherit !important;
}

image {
  width: 100%;
  height: 100%;
  display: block;
}
.u-line-99 {
  display: -webkit-box !important;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-all;
  -webkit-line-clamp: 99;
  -webkit-box-orient: vertical !important;
}
// 解决u-image组件100%无效
.uImgWrap .u-transition {
  width: 100%;
  height: 100%;
}
.u-radio-group {
  justify-content: space-between;
}
</style>
